<?php
header("content-type:text/html;charset=utf-8");
// ==================php  门面模式(外观模式)  =============================
 /* 其实门面模式就是把几个子系统(实例或者类.统一一个统一的接口进行执行,客户端不用关注子系统,只用门面即可 )*/

// 门面抽象接口 
interface Facade{   
    public function turnOn() ;
    public function turnOff() ;
}
 
// (1) 关闭显示器
class PcLight {
    public function turnOn() {}
    public function turnOff() {
        echo 'turn off PcLight <br>' ;
    }   
}

//(2) pc 机器
class Pcmachine {
    public function turnOn() {} 
    public function turnOff() {
        echo 'turn off PcMathion <br>' ;
    }
}
 
// (3) 关闭电源
class Power {
    public function turnOn() {} 
    public function turnOff() {
        echo 'turn off Power <br>' ;
    }
}
 
// 关机的门面角色 
class PcFacade implements Facade{
     
    private  $PcLight ; 
    private  $Pcmachine ; 
    private  $Power ; 
  
    public function __construct(){
     $this->PcLight = new PcLight();
         $this->Pcmachine = new Pcmachine();
         $this->Power = new Power();
    }
     
    // 门面角色的应用
     public function turnOff() { 
          $this->PcLight ->turnOff();
          $this->Pcmachine ->turnOff();
          $this->Power ->turnOff();
     }
      public function turnOn() {}
}
 
// 应用
$button = new PcFacade(); 
$button ->turnOff(); 